package config

import (
	"encoding/json"
	"io/ioutil"

	"gitee.com/yutiandou/wdtools/wdlog"
)

type Config struct {
	LUAddress        string //"127.0.0.1:1314"
	Address          string //"127.0.0.1：8080"
	ServerName       string
	Weight           int
	MaxConnectCount  uint32
	MaxIdleTime      int64
	MaxMessageLength uint32
	MaxQueueLength   int
}

var Conf = &Config{
	LUAddress:       `127.0.0.1:1314`,
	Address:         `127.0.0.1:8080`,
	ServerName:      "wdRPG",
	Weight:          100,
	MaxConnectCount: 1204,
	MaxIdleTime:     60,
}

func LoadUpConfig(path string) {
	data, err := ioutil.ReadFile(path)
	if wdlog.PanicErr(err) {
		return
	}
	err = json.Unmarshal(data, Conf)
	if wdlog.PanicErr(err) {
		return
	}
}
